(function(angular) {
	'use strict';
	angular.module("fs.waf").factory("collateralService", collateralService);
	collateralService.$inject = [ '$q', 'loggerFactory' , 'storageService'];
	function collateralService($q, loggerFactory, storageService) {
		var log = loggerFactory.getLogger("collateralService");
		
		function initData ($scope, ctrl) {
			ctrl.collateral = {};
			ctrl.collateral.siteCode = storageService.getUserInfo().siteCode;
			ctrl.changeCollateralName = function(){
				if ( ctrl.collateral && ctrl.collateral.collateralName){				
					ctrl.collateral.collateralCode = ctrl.collateral.siteCode + "-" + ctrl.collateral.collateralName;
				} else {
					if ( ctrl.collateral){
						ctrl.collateral.collateralCode = null;
					}
				}
			};
		}
		
		return {
			initData  : initData
		};
	}
})(angular);